package com.tensquare.test.qa.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.tensquare.test.qa.pojo.Problem;
import org.springframework.data.jpa.repository.Query;

/**
 * 数据访问接口
 * @author Administrator
 *
 */
public interface ProblemDao extends JpaRepository<Problem,String>,JpaSpecificationExecutor<Problem>{
	//最新，热门，等待
    @Query(value = "SELECT * FROM tb_problem, tb_pl WHERE id = problemid AND labelid =? ORDER by  replytime DESC " ,nativeQuery = true)
    public Page<Problem> newList(String labelid, Pageable pageable);

    @Query(value = "SELECT * FROM tb_problem, tb_pl WHERE id = problemid AND labelid =? ORDER by  reply DESC " ,nativeQuery = true)
    public Page<Problem> hotList(String labelid, Pageable pageable);

    @Query(value = "SELECT * FROM tb_problem, tb_pl WHERE id = problemid AND labelid =? AND reply=0 ORDER by  createtime DESC " ,nativeQuery = true)
    public Page<Problem> waitList(String labelid, Pageable pageable);
}
